/**
 * 
 */
package com.diet263.utils;

import android.util.Log;

/**
 * 对Log类的修饰,通过IS_SHOW_LOG常量可以控制整个应用是否打印日志到控制台
 * 
 * @author simon
 *
 */
public class MyLog {

	/**
	 * 通过IS_SHOW_LOG参数统一控制全局Log日志的是否打�?br/>
	 * <br/>
	 * IS_SHOW_LOG为true,表示打印日志;<br/>
	 * <br/>
	 * IS_SHOW_LOG为false，表示不打印日志
	 */
	private static final boolean IS_SHOW_LOG = true;

	private MyLog() {
	}

	/**
	 * Send an {@link #INFO} log message.
	 * 
	 * @param tag
	 *            Used to identify the source of a log message. It usually
	 *            identifies the class or activity where the log call occurs.
	 * @param msg
	 *            The message you would like logged.
	 */
	public static int i(String tag, String msg) {
		if (IS_SHOW_LOG) {
			return Log.i(tag, msg);
		} else {
			return -1;
		}
	}

	/**
	 * Send an {@link #ERROR} log message.
	 * 
	 * @param tag
	 *            Used to identify the source of a log message. It usually
	 *            identifies the class or activity where the log call occurs.
	 * @param msg
	 *            The message you would like logged.
	 */
	public static int e(String tag, String msg) {
		if (IS_SHOW_LOG) {
			return Log.e(tag, msg);
		} else {
			return -1;
		}
	}

	/**
	 * Send a {@link #DEBUG} log message.
	 * 
	 * @param tag
	 *            Used to identify the source of a log message. It usually
	 *            identifies the class or activity where the log call occurs.
	 * @param msg
	 *            The message you would like logged.
	 */
	public static int d(String tag, String msg) {
		if (IS_SHOW_LOG) {
			return Log.d(tag, msg);
		} else {
			return -1;
		}
	}

	/**
	 * Send a {@link #WARN} log message.
	 * 
	 * @param tag
	 *            Used to identify the source of a log message. It usually
	 *            identifies the class or activity where the log call occurs.
	 * @param msg
	 *            The message you would like logged.
	 */
	public static int w(String tag, String msg) {
		if (IS_SHOW_LOG) {
			return Log.w(tag, msg);
		} else {
			return -1;
		}
	}

	/**
	 * Send a {@link #VERBOSE} log message.
	 * 
	 * @param tag
	 *            Used to identify the source of a log message. It usually
	 *            identifies the class or activity where the log call occurs.
	 * @param msg
	 *            The message you would like logged.
	 */
	public static int v(String tag, String msg) {
		if (IS_SHOW_LOG) {
			return Log.v(tag, msg);
		} else {
			return -1;
		}
	}

	/**
	 * What a Terrible Failure: Report a condition that should never happen. The
	 * error will always be logged at level ASSERT with the call stack.
	 * Depending on system configuration, a report may be added to the
	 * {@link android.os.DropBoxManager} and/or the process may be terminated
	 * immediately with an error dialog.
	 * 
	 * @param tag
	 *            Used to identify the source of a log message.
	 * @param msg
	 *            The message you would like logged.
	 */
	public static int wtf(String tag, String msg) {
		if (IS_SHOW_LOG) {
			return Log.wtf(tag, msg);
		} else {
			return -1;
		}
	}

	/**
	 * Low-level logging call.
	 * 
	 * @param priority
	 *            The priority/type of this log message
	 * @param tag
	 *            Used to identify the source of a log message. It usually
	 *            identifies the class or activity where the log call occurs.
	 * @param msg
	 *            The message you would like logged.
	 * @return The number of bytes written.
	 */
	public static int println(int priority, String tag, String msg) {
		if (IS_SHOW_LOG) {
			return Log.println(priority, tag, msg);
		} else {
			return -1;
		}
	}

	/**
	 * Checks to see whether or not a log for the specified tag is loggable at
	 * the specified level.
	 *
	 * The default level of any tag is set to INFO. This means that any level
	 * above and including INFO will be logged. Before you make any calls to a
	 * logging method you should check to see if your tag should be logged. You
	 * can change the default level by setting a system property: 'setprop
	 * log.tag.&lt;YOUR_LOG_TAG> &lt;LEVEL>' Where level is either VERBOSE,
	 * DEBUG, INFO, WARN, ERROR, ASSERT, or SUPPRESS. SUPPRESS will turn off all
	 * logging for your tag. You can also create a local.prop file that with the
	 * following in it: 'log.tag.&lt;YOUR_LOG_TAG>=&lt;LEVEL>' and place that in
	 * /data/local.prop.
	 *
	 * @param tag
	 *            The tag to check.
	 * @param level
	 *            The level to check.
	 * @return Whether or not that this is allowed to be logged.
	 * @throws IllegalArgumentException
	 *             is thrown if the tag.length() > 23.
	 */
	public static boolean isLoggable(String tag, int level) {
		if (IS_SHOW_LOG) {
			return Log.isLoggable(tag, level);
		} else {
			return false;
		}
	}

}
